// pages/deposit/deposit.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    color:'#019B43',
    color2: '#F0F0F0',
    checked:true,
    inputHidden:true,
    bankname:'中国银行',
    bankCart:'',
    zhanghao:'',
    ttype:1
  },

  /**
   * 生命周期函数--监听页面加载  #019B43
   */
  radio1:function (e) {
    var that = this;
    that.setData({
      color:'#019B43',
      color2:'#F0F0F0',
      inputHidden:true,
      ttype:1
    })
  },
  radio2: function (e) {
    var that = this;
    that.setData({
      color2: '#019B43',
      color:'#F0F0F0',
      inputHidden:false,
      ttype:2
    })
  },
  onLoad: function (options) {
    var that = this;
    var bankname = options.bankname;
    if(bankname != '' && bankname != null){
      that.setData({
        bankname:bankname
      });
    }
  },
  selectBank:function () {
    wx.redirectTo({
      url: '../selectBank/selectBank',
    })
  },
  getCart:function (e) {
    var bankCart = e.detail.value;
    this.setData({
      bankCart: bankCart
    });
  },
  getTotal: function (e) {
    var total = e.detail.value;
    this.setData({
      total: total
    });
  },
  getZhanghao: function (e) {
    var zhanghao = e.detail.value;
    this.setData({
      zhanghao: zhanghao
    });
  },
  send:function () {
    var that = this;
    wx.request({
      url: app.d.ceshiUrl + '/Api/Doctor/tixian',
      method: "post",
      data: {
        uid: app.d.userId,
        ttype: that.data.ttype,
        bankname: that.data.bankname,
        bankCart: that.data.bankCart,
        zhanghao:that.data.zhanghao,
        total: that.data.total,
      },
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if (res.data.status == 1) {
          wx.showToast({
            title: res.data.err,
            duration:2000
          })
          setTimeout(function () {
           wx.navigateBack({
             
           })
          }, 2000);
        } else {
          wx.showToast({
            title: res.data.err,
          })
        }
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 30000
        });
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})